home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <graphics.h>
-
- main()
- {
- int graphdriver = DETECT, graphmode;
- char buffer[80];
- int xasp, yasp, bcolor, width;
-
- initgraph(&graphdriver, &graphmode, "c:\\turboc");
- bcolor = getbkcolor();
- setfillstyle(EMPTY_FILL, 0);
- settextjustify(LEFT_TEXT,BOTTOM_TEXT);
- /* Get the current "aspect ratio" and display it */
- getaspectratio( &xasp, &yasp );
- sprintf(buffer,"Aspect ratio: xasp = %d, yasp = %d", xasp, yasp);
- outtextxy(100,30, buffer);
- width = textwidth(buffer);
- outtextxy(100,10,"Enter xasp, yasp (0,0 to exit): ");
- /* Draw a circle */
- setcolor(RED);
- circle(120,120, 80);
- /* Now let user alter the aspect ratio */
- while(1)
- {
- /* Read new aspect ratio parameters */
- scanf(" %d , %d", &xasp, &yasp);
- /* Exit if either xasp or yasp is 0 */
- if(xasp == 0 || yasp == 0) break;
- /* Erase the previous circle */
- setcolor(bcolor);
- circle(120,120, 80);
- /* Set the aspect ratio and redraw it */
- setaspectratio(xasp,yasp);
- setcolor(RED);
- circle(120,120, 80);
- /* Display the new aspect ratio */
- bar(100, 30-textheight("H"), 100+width, 30);
- sprintf(buffer,"Aspect ratio: xasp = %d, yasp = %d", xasp, yasp);
- outtextxy(100,30, buffer);
- }
- closegraph(); /* Exit graphics library */
- }